package com.haidechizi.leetcode;

import java.util.LinkedList;
import java.util.Queue;

public class _1248_统计优美子数组 {


    public int numberOfSubarrays(int[] nums, int k) {

        int count = 0;
        int sum = 0;
        Queue<Integer> queue = new LinkedList<>();
        for (int i = 0; i < nums.length; i++) {
            if (count == k && isJishu(nums[i])) {
                Integer poll = queue.poll();
                if (isJishu(poll)) {
                    count--;
                }
                count++;
            }
            queue.add(nums[i]);
            if (isJishu(nums[i])) {
                count++;
            }
            if (count == k) {
                sum++;
            }


        }
        return -1;

    }

    public boolean isJishu(int i) {
        return i % 2 == 1;
    }
}
